package com.alex.server.util;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

public class TokenUtil {

    public static final String Salt = "gmcwy";

    public static String createToken (String userName, String password) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        StringBuffer sb = new StringBuffer();
        sb.append(userName);
        sb.append(password);
        sb.append(Salt);
        String en = MD5.EncoderPwdByMd5(sb.toString());
        StringBuffer sbToken = new StringBuffer();
        sbToken.append(en);
        sbToken.append(RandomUtils.generateMixString(64));
        return sbToken.toString();
    }

    public static void main(String[] args) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        System.out.println(createToken("system","123454"));
    }
}
